<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function login(){
				var $uname=uname.value;
				var $upwd=upwd.value;
				if(!$uname){alert("用户名不能为空");return}
				if(!$upwd){alert("密码不能为空");return}
				var xhr=new XMLHttpRequest();
				xhr.onreadystatechange=function(){
					if(xhr.readyState==4 && xhr.status==200){
						var r=xhr.responseText;
						d1.innerHTML=r;
					}
				}
				xhr.open("post","/ajax/post_login",true);
				var formdata=`uname=${$uname}&upwd=${$upwd}`;
				xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xhr.send(formdata);
			}
		</script>
	</head>
	<body>
		<input type="text" id="uname"><br>
		<input type="text" id="upwd"><br>
		<button onclick="login()">登录</button>
		<div id="d1">
			
		</div>
	</body>
</html>
